package com.xingxing.Adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.xingxing.Activity.R;
import com.xingxing.Bean.CostRecord;

import java.util.List;

public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MyViewHolder> {
    List<CostRecord> costRecord;
    private Context mContext;

    public MessageAdapter(Context context, List<CostRecord> costRecord) {
        mContext = context;
        this.costRecord = costRecord;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder = new MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.recycler_item_message, parent, false));
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, @SuppressLint("RecyclerView") int position) {
        holder.orderId.setText(costRecord.get(position).getOrderId());
        holder.date.setText(costRecord.get(position).getDate());
        holder.cost.setText("-" + costRecord.get(position).getCost() + "元");
    }

    @Override
    public int getItemCount() {
        return costRecord.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        TextView orderId;
        TextView date;
        TextView cost;
        com.xuexiang.xui.widget.imageview.RadiusImageView item;

        public MyViewHolder(View view) {
            super(view);
            orderId = (TextView) view.findViewById(R.id.order_id_value);
            date = (TextView) view.findViewById(R.id.date_value);
            cost = (TextView) view.findViewById(R.id.cost);
            item = (com.xuexiang.xui.widget.imageview.RadiusImageView) view.findViewById(R.id.round_background);
        }
    }
}